package com.cheyun.netsalev3.bean

import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
import com.cheyun.netsalev3.BR
import com.cheyun.netsalev3.utils.FunctionUtils

data class MyData(
        val arrive: Int,
        val deliver: Int,
        val failure: Int,
        val follow_doing: Int,
        val follow_out: Int,
        val followed: Int,
        val group: String,
        val invite: Int,
        val order: Int,
        val uname: String
) : BaseObservable() {
    @get:Bindable
    var IsSelect: Boolean? = false
        set(isSelect) {
            field = isSelect
            notifyPropertyChanged(BR.isSelect)
        }
    //头部item选中位置   用于筛选数据
    private var topPosition = 0
    var names = arrayListOf("今日邀约", "今日到店", "今日订车", "今日提车",
            "等待跟进", "已经跟进", "跟进逾期", "虚假战败")
    //内容显示
    var conttString = ""
    //头部内容
    var topName = ""
    var topCunt = ""

    fun initData() {
        names = arrayListOf("今日邀约", "今日到店", "今日订车", "今日提车",
                "等待跟进", "已经跟进", "跟进逾期", "虚假战败")
        topPosition = 0
        IsSelect = false


    }


    /**
     * 筛选数据
     */
    private fun getData(s: String): String {
        when (s) {
            "今日邀约" -> return invite.toString()
            "今日到店" -> return arrive.toString()
            "今日订车" -> return order.toString()
            "今日提车" -> return deliver.toString()
            "等待跟进" -> return follow_doing.toString()
            "已经跟进" -> return followed.toString()
            "跟进逾期" -> return follow_out.toString()
            "虚假战败" -> return failure.toString()
        }
        return ""
    }

    /**
     * 设置选中top位置
     */
    fun setTopPosition(topPosition: Int) {
        this.topPosition = topPosition
        getTextContent()
        getTextTop()
    }

    /**
     * 获取显示头部数据
     */
    private fun getTextTop() {
        topName = names[topPosition]
        topCunt = getData(names[topPosition])
    }

    /**
     * 获取显示字符串
     */
    private fun getTextContent() {
        var temlist = ArrayList<String>()
        for (i in names.indices) {
            temlist.add(names[i])
        }
        conttString = ""
        for (i in 0 until temlist.size) {
            var name = temlist[i]
            conttString = if (i % 3 == 2) {
                conttString + "·$name&ensp;" + "<font color=\"#546478\">" + FunctionUtils.stringLeng(getData(name)) + "</font><br>"
            } else {
                conttString + "·$name&ensp;" + "<font color=\"#546478\">" + FunctionUtils.stringLeng(getData(name)) + "</font>&ensp;&ensp;"
            }
        }

    }
}